如何在tkinter窗口中打开web浏览器

您所在的位置:网站首页 python tkinter web 如何在tkinter窗口中打开web浏览器

如何在tkinter窗口中打开web浏览器

#如何在tkinter窗口中打开web浏览器| 来源: 网络整理| 查看: 265

我知道这个问题以前已经解决过了,但我找不到一个与我的项目相关的解决方案。我的项目是一个超文本标记语言编辑器/解释器,它使用webbrowser模块在web浏览器上运行给定的超文本标记语言代码。我希望能够在我的tkinter窗口中打开web浏览器,而不是在实际的浏览器中。我如何在我的程序中实现这一点?我的一些代码:

import tkinter as tk from tkinter.filedialog import askopenfilename, asksaveasfilename from tkinter import messagebox import webbrowser import os window = tk.Tk() window.title("HTML Editor") window.configure(bg="grey") window.state("zoomed") title = tk.Label(window, text="HTML Editor", font=("Arial Rounded MT Bold", 40, "underline"), bg="grey") title.place(x=400, y=20) def run_code(): window_title = window.title() index = window_title.index("-") + 2 window_title = window_title[index::] with open(window_title, "w") as path: content = text_box.get("1.0", tk.END) path.write(content) basename = os.path.basename(window_title) new_file = open(basename, "w") new_file.write(content) new_file.close() webbrowser.open_new_tab("file:///" + os.getcwd() + "/" + basename) def get_stringvar(event): line = text_box.get("insert linestart", "insert") if (line[-1] == ">") and ("


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3